package org.jeecg.modules.health_records.health_vacc.service.impl;

import org.jeecg.modules.health_records.health_vacc.entity.HealthVaccInfo;
import org.jeecg.modules.health_records.health_vacc.mapper.HealthVaccInfoMapper;
import org.jeecg.modules.health_records.health_vacc.service.IHealthVaccInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 接种疫苗记录
 * @Author: jeecg-boot
 * @Date:   2025-06-26
 * @Version: V1.0
 */
@Service
public class HealthVaccInfoServiceImpl extends ServiceImpl<HealthVaccInfoMapper, HealthVaccInfo> implements IHealthVaccInfoService {
    @Autowired
    private HealthVaccInfoMapper healthVaccInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthVaccInfo> queryByRecordId(HealthVaccInfo healthVaccInfo) {
        return healthVaccInfoMapper.queryByRecordId(Long.valueOf(healthVaccInfo.getRecordid()),healthVaccInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthVaccInfo> queryElecRecord(HealthVaccInfo healthVaccInfo) {
        return healthVaccInfoMapper.queryElecRecord(Long.valueOf(healthVaccInfo.getRecordid()),healthVaccInfo.getIdNumber());

    }
    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthVaccInfo> newQueryElecRecord(HealthVaccInfo healthVaccInfo) {
        return healthVaccInfoMapper.newQueryElecRecord(Long.valueOf(healthVaccInfo.getRecordid()),healthVaccInfo.getSeeId(),healthVaccInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthVaccInfo> newQueryPastRecord(HealthVaccInfo healthVaccInfo) {
        return healthVaccInfoMapper.newQueryPastRecord(Long.valueOf(healthVaccInfo.getRecordid()),healthVaccInfo.getSeeId(),healthVaccInfo.getIdNumber());

    }

}
